<?php

/**
 * Cliente form base class.
 *
 * @method Cliente getObject() Returns the current form's model object
 *
 * @package    sms
 * @subpackage form
 * @author     Patricio Andrés Córdova De La Cruz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseClienteForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_cliente'         => new sfWidgetFormInputHidden(),
      'cedula'             => new sfWidgetFormInputText(),
      'nombre_cliente'     => new sfWidgetFormInputText(),
      'apellido_cliente'   => new sfWidgetFormInputText(),
      'nombre_preferido'   => new sfWidgetFormInputText(),
      'telefono_domicilio' => new sfWidgetFormInputText(),
      'celular'            => new sfWidgetFormInputText(),
      'email'              => new sfWidgetFormInputText(),
      'id_operadora'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Operadora'), 'add_empty' => false)),
      'fecha_nacimiento'   => new sfWidgetFormDate(),
      'observaciones'      => new sfWidgetFormInputText(),
      'id_sucursal'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Sucursal'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'id_cliente'         => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_cliente')), 'empty_value' => $this->getObject()->get('id_cliente'), 'required' => false)),
      'cedula'             => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'nombre_cliente'     => new sfValidatorString(array('max_length' => 128)),
      'apellido_cliente'   => new sfValidatorString(array('max_length' => 128)),
      'nombre_preferido'   => new sfValidatorInteger(array('required' => false)),
      'telefono_domicilio' => new sfValidatorString(array('max_length' => 12, 'required' => false)),
      'celular'            => new sfValidatorString(array('max_length' => 12)),
      'email'              => new sfValidatorString(array('max_length' => 32, 'required' => false)),
      'id_operadora'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Operadora'))),
      'fecha_nacimiento'   => new sfValidatorDate(array('required' => false)),
      'observaciones'      => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'id_sucursal'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Sucursal'), 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('cliente[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Cliente';
  }

}
